package com.witframework.core.schedule;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public abstract class SystemInformation
{
   
    public static native int    getProcessID ();    
   
    public static native long   getProcessCPUTime ();
  
    public static native double getProcessCPUUsage ();       
    
    private SystemInformation () {} // prevent subclassing
    
    private static final String SILIB = "silib";
    
    static{
    	String root_path =Thread.currentThread().getClass().getResource("/application-config.xml").getPath();
    	root_path=root_path.substring(0,root_path.lastIndexOf("/"));
    	root_path=root_path.substring(0,root_path.lastIndexOf("/"));
    	try {
			root_path = URLDecoder.decode(root_path,"GBK");
		} catch (UnsupportedEncodingException e1) {		
			e1.printStackTrace();
		}
        try
        {
            System.load (root_path+"/lib/"+"silib.dll");
        }
        catch (UnsatisfiedLinkError e)
        {
            System.out.println ("native lib '" + SILIB + "' not found in 'java.library.path': " + System.getProperty ("java.library.path"));            
            throw e; // re-throw
        }
    }
    public static void main(String[] args) {
    	System.out.println(getProcessCPUUsage());
	}
} 
